<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>个人信息</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/bootstrap.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/index.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/toastr/toastr.min.css">
    <script src="${pageContext.request.contextPath}/static/js/jquery-3.4.1.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="${pageContext.request.contextPath}/static/toastr/toastr.min.js"></script>
    <script src="${pageContext.request.contextPath}/static/js/bootstrap.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="${pageContext.request.contextPath}/static/echars/echarts.min.js" type="text/javascript" charset="utf-8"></script>
    <style>
        #xia {
            width: 50%;
        }
        .panel {
            width: 100%;
            margin-left: 0px;
        }
    </style>
</head>
<body>
<div style="height: 10px"></div>
<div class="col-lg-offset-2 col-md-8">
    <div class="panel panel-default" style="border: #00a2e8 solid 1px">
        <div class="panel-heading" style="background: #29a3ffd1;color: #fff;">新闻/活动公告</div>
        <div class="panel-body">
            <div class="row">
                <div class="col-md-6">
                    <div class="input-group">
                        <span class="input-group-addon">员工ID</span>
                        <input class="form-control" value="${staff.staffId}" disabled>
                    </div>
                </div>
                <div class="col-md-6">
                    <div class="input-group">
                        <span class="input-group-addon">员工姓名</span>
                        <input class="form-control" value="${staff.staffName}" disabled>
                    </div>
                </div>
            </div>
            <div style="height: 15px"></div>
            <div class="row">
                <div class="col-md-6">
                    <div class="input-group">
                        <span class="input-group-addon">员工电话</span>
                        <input class="form-control" value="${staff.phone}" disabled>
                    </div>
                </div>
                <div class="col-md-6">
                    <div class="input-group">
                        <span class="input-group-addon">员工身份证号码</span>
                        <input class="form-control" value="${staff.idCard}" disabled>
                    </div>
                </div>
            </div>
            <div style="height: 15px"></div>
            <div class="row">
                <div class="col-md-6">
                    <div class="input-group">
                        <span class="input-group-addon">员工地址</span>
                        <input class="form-control" value="${staff.address}" disabled>
                    </div>
                </div>
                <div class="col-md-6">
                    <div class="input-group">
                        <span class="input-group-addon">入职日期</span>
                        <input class="form-control" value="${staff.createdTime}" disabled>
                    </div>
                </div>
            </div>
            <div style="height: 15px"></div>
        </div>
    </div>

    <!--    下方面板-->
    <div id="xia">
        <div class="panel panel-default" style="border: #00a2e8 solid 1px">
            <div class="panel-heading" style="background: #29a3ffd1;color: #fff;">修改密码</div>
            <div class="panel-body">
                <div class="row">
                    <div class="col-md-6">
                        <div class="input-group">
                            <span class="input-group-addon">新密码</span>
                            <input type="password" class="form-control" id="password" name="password">
                        </div>
                    </div>
                </div>
                <div style="height: 15px;"></div>
                <div class="row">
                    <div class="col-md-6">
                        <div class="input-group">
                            <span class="input-group-addon">确认密码</span>
                            <input type="password" class="form-control" id="confirmPass">
                        </div>
                    </div>
                </div>
                <div style="height: 15px;"></div>
                <button id="updatePass" class="btn-success btn">确认修改</button>
            </div>
        </div>
    </div>
    <!--    下方面板-->
</div>
<script type="text/javascript">
    $("#updatePass").on("click",function () {
        let pass1=$("#password").val();
        let pass2=$("#confirmPass").val();
        let passVer=/^[a-z A-Z 0-9]{6,10}$/;
        if (passVer.test(pass1) && passVer.test(pass2)) {
            if (pass1 == pass2) {
                if (pass2 !=${staff.password}) {
                    $.post(
                        "/staffController/updatePass",
                        {password: pass2, id:${staff.id}},
                        function (data) {
                            if (data == 1) {
                                toastr.success("修改成功");
                                $("#password").val("");
                                $("#confirmPass").val("");
                            } else {
                                toastr.error("修改失败,原因未知");
                            }
                        }
                    );
                } else {
                    toastr.warning("新密码不能与旧密码相同");
                    $("#password").val("");
                    $("#confirmPass").val("");
                }
            } else {
                toastr.warning("两次密码不一致");
            }
        } else {
            toastr.warning("密码只能是6-10位\n只能包含字母数字");
        }
    })
</script>
</body>
</html>